package{
	import com.hurlant.eval.ast.Void;
	import com.tools.EventHelper;
	import com.tools.PQDrawTools;
	import com.tools.UIHelper;
	
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.events.MouseEvent;
	import flash.text.TextField;
	import flash.text.TextFieldType;

	public class MenuView extends Sprite{
		public var boder:Sprite;
		public var pad:int=550;
		public var w:int=60;
		public var h:int=27;
		public var btn_addMc:Sprite;
		public var btn_addTxt:Sprite;
		public var btn_setTop:Sprite;
		public var btn_showAll:Sprite;
		public var btn_clear:Sprite;
		public var btn_submit:Sprite;
		public var btn_remove:Sprite;
		public var txt_class:TextField;
		public var txt_tip:TextField;
		public var panel:Sprite;
		public function MenuView(){
			super();
			init();
		}
		public function init():void{
			boder=new Sprite();
			addChild(boder);
			panel=new Sprite();
			addChild(panel);
			btn_addMc=UIHelper.self.createBtn("btn_addMc",this,[PQDrawTools.drawRoundRect(0,0,60,25,1,0x333333,0xcccccc,1,10),UIHelper.self.createLabel({text:"添加容器",width:60,height:25,x:0,y:2,align:"center"})],10,10,60,h);
			btn_addTxt=UIHelper.self.createBtn("btn_addTxt",this,[PQDrawTools.drawRoundRect(0,0,60,25,1,0x333333,0xcccccc,1,10),UIHelper.self.createLabel({text:"添加文本",width:60,height:25,x:0,y:2,align:"center"})],80,10,60,h);
			btn_setTop=UIHelper.self.createBtn("btn_setTop",this,[PQDrawTools.drawRoundRect(0,0,60,25,1,0x333333,0xcccccc,1,10),UIHelper.self.createLabel({text:" 置 顶 ",width:60,height:25,x:0,y:2,align:"center"})],150,10,60,h);
			
			btn_showAll=UIHelper.self.createBtn("btn_showAll",panel,[PQDrawTools.drawRoundRect(0,0,60,25,1,0x333333,0xcccccc,1,10),UIHelper.self.createLabel({text:"显示全部",width:60,height:25,x:0,y:2,align:"center"})],pad,2,60,h);
			btn_clear=UIHelper.self.createBtn("btn_clear",panel,[PQDrawTools.drawRoundRect(0,0,60,25,1,0x333333,0xcccccc,1,10),UIHelper.self.createLabel({text:"清空所有",width:60,height:25,x:0,y:2,align:"center"})],pad+w+10,2,60,h);
			btn_submit=UIHelper.self.createBtn("btn_submit",panel,[PQDrawTools.drawRoundRect(0,0,60,25,1,0x333333,0xcccccc,1,10),UIHelper.self.createLabel({text:"提交发布",width:60,height:25,x:0,y:2,align:"center"})],pad+w*2+20,2,60,h);
			btn_remove=UIHelper.self.createBtn("btn_remove",panel,[PQDrawTools.drawRoundRect(0,0,60,25,1,0x333333,0xcccccc,1,10),UIHelper.self.createLabel({text:"移  除",width:60,height:25,x:0,y:2,align:"center"})],pad+w*3+30,2,60,h);
			txt_class=UIHelper.self.createTxt({text:"类名",align:"center",type:TextFieldType.INPUT,size:16,x:pad,y:28,width:60,height:20,border:1,parent:panel});
			txt_tip=UIHelper.self.createLabel({text:"设置并拖入SWF后会从SWF中提取对应的资源并显示",align:"left",size:10,x:pad+60,y:30,width:600,height:20,parent:panel});
			txt_class.addEventListener(Event.CHANGE,updateClassName);
			txt_class.mouseEnabled=true;
			btn_addMc.addEventListener(MouseEvent.CLICK,addMc);
			btn_addTxt.addEventListener(MouseEvent.CLICK,addTxt);
			btn_setTop.addEventListener(MouseEvent.CLICK,setTop);
			btn_showAll.addEventListener(MouseEvent.CLICK,showAll);
			btn_clear.addEventListener(MouseEvent.CLICK,clear);
			btn_submit.addEventListener(MouseEvent.CLICK,submit);
			btn_remove.addEventListener(MouseEvent.CLICK,remove);
		}
		private function addMc(e:MouseEvent):void{
			EventHelper.self.call(EventType.ADD_MC);
		}
		private function addTxt(e:MouseEvent):void{
			EventHelper.self.call(EventType.ADD_TXT);
		}
		private function setTop(e:MouseEvent):void{
			EventHelper.self.call(EventType.SET_TOP);
		}
		private function showAll(e:MouseEvent):void{
			EventHelper.self.call(EventType.SHOW_ALL);
		}
		private function clear(e:MouseEvent):void{
			EventHelper.self.call(EventType.CLEAR);
		}
		private function submit(e:MouseEvent):void{
			EventHelper.self.call(EventType.SUBMIT);
		}
		private function remove(e:MouseEvent):void{
			EventHelper.self.call(EventType.REMOVE);
		}
		public function update():void{
			boder.graphics.clear();
			boder.graphics.beginFill(0xcccccc);
			boder.graphics.drawRect(0,0,stage.stageWidth-150,50);
			boder.graphics.endFill();
			boder.graphics.lineStyle(1,0x000000);
			boder.graphics.drawRect(0,0,stage.stageWidth-150,50);
			panel.x=boder.width-panel.width-200;
		}
		public function updateClassName(e:Event):void{
			Config.self.className=txt_class.text;
		}
	}
}